package com.joseph.test;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @description 
 * @author Joseph_Mok
 * @date 2016年4月8日上午11:42:25
 */
public class Singleton02 {
	
	private static class InstanceHolder {
		 private static final Singleton02 INSTANCE = new Singleton02();  
	}
	
	public static final Singleton02 getInstance() {
		return InstanceHolder.INSTANCE;
	}
	
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
		Constructor <Singleton02> cons =  Singleton02.class.getDeclaredConstructor();
		Singleton02 s1 = cons.newInstance();
		Singleton02 s2 = cons.newInstance();
		System.out.println(s1 == s2);
		Singleton02 s3 = Singleton02.getInstance();
		Singleton02 s4 = Singleton02.getInstance();
		System.out.println(s3 == s4);
	}
}
